package ltd.jdsoft.cute.common.reflect;

import java.lang.reflect.Method;

/**
 * 扩展节点反射并clone
 * 
 * @author zhengzhq
 *
 */
public class ExtensionReflect {

  private static final String SET_VALUE_METHOD_NAME = "setValue";

  /**
   * 对扩展节点进行反射设置值
   * 
   * @param extension
   * @param value
   */
  public static void setValue(Object extension, String value) {
    try {
      Method method = extension.getClass().getMethod(SET_VALUE_METHOD_NAME, String.class);
      method.invoke(extension, value);
    } catch (Exception e) {
      throw new IllegalArgumentException(
          "reflect extension[" + extension.getClass().getName() + "] error", e);
    }
  }
}
